<?php	

/**
 * 
 *
 * @version $Id: perm.inc.php,v 1.8 2005/01/05 13:36:39 phppc Exp $
 * @copyright 2004 
 **/

unset($perm_field);
$this->uf_field[14] = "name";
	$this->uf_input[14]["size"] = 15;
	$this->uf_input[14]["ml"] = 30;
$this->uf_field[1] = "acp_access";
	$this->uf_input[1]["type"] = "yes_no";
$this->uf_field[2] = "news_edit_del";
	$this->uf_input[2]["type"] = "input_name";
	$this->uf_input[2]["start"] = 0;
	$this->uf_input[2]["ende"] = 2;
	$this->uf_input[2]["style"]["type"] = "standard";
$this->uf_field[3] = "news_write";
	$this->uf_input[3]["type"] = "input_name";
	$this->uf_input[3]["start"] = 0;
	$this->uf_input[3]["ende"] = 2;
	$this->uf_input[3]["style"]["type"] = "standard";
$this->uf_field[16] = "news_act";
	$this->uf_input[16]["type"] = "yes_no";
$this->uf_field[4] = "news_sig";
	$this->uf_input[4]["type"] = "yes_no";
$this->uf_field[5] = "news_anhang";
	$this->uf_input[5]["type"] = "yes_no";
$this->uf_field[6] = "kat_new";
	$this->uf_input[6]["type"] = "yes_no";
$this->uf_field[7] = "kat_edit_del";
	$this->uf_input[7]["type"] = "yes_no";
$this->uf_field[8] = "user_new";
	$this->uf_input[8]["type"] = "yes_no";
$this->uf_field[9] = "user_edit";
	$this->uf_input[9]["type"] = "yes_no";
$this->uf_field[10] = "user_edit_group";
	$this->uf_input[10]["type"] = "yes_no";
$this->uf_field[11] = "group_new";
	$this->uf_input[11]["type"] = "yes_no";
$this->uf_field[12] = "group_edit_del";
	$this->uf_input[12]["type"] = "yes_no";
$this->uf_field[13] = "news_com";
	$this->uf_input[13]["type"] = "input_name";
	$this->uf_input[13]["start"] = 0;
	$this->uf_input[13]["ende"] = 2;
	$this->uf_input[13]["style"]["type"] = "standard";
$this->uf_field[15]	= "com_edit_del";
	$this->uf_input[15]["type"] = "input_name";
	$this->uf_input[15]["start"] = 0;
	$this->uf_input[15]["ende"] = 2;
	$this->uf_input[15]["style"]["type"] = "standard";

$perm = $this->fun_sg2var("perm");
$perms_array = array();
if($this->perm_array["group_new"] == 1) array_push($perms_array,"new");
if($this->perm_array["group_edit_del"] == 1) array_push($perms_array,"edit","do_edit","del");
$perm = $this->uf_form_conf_def($perm,$perms_array,"show");
$this->module_new_value["action"] = "perm";
 
if ($perm == "show") {
	$abfrage = "SELECT id,name FROM ".$this->config["prefix"]."perm";
    $erg = $this->db_abfrage_q($abfrage);
    $perm_ones = "";
	while($perm = $this->db_abfrage_fetch($erg)){
		$this->tpl_load("perm_show_one","admin/");
		$edit_link = $this->fun_make_link("admin.php","perm=edit&perm_id&perm_id=".$perm["id"]);
		$this->tpl_replace_vars(array("perm_name" => $perm["name"], "perm_id" => $perm["id"],"edit_link" => $edit_link));
		$perm_ones .= $this->tpl_output();
	} // while
	$hidden_array["perm"] = "new";
	if ($this->perm_array["group_new"] == 1) $perm_new_input = $this->uf_create_complete_form("admin_perm_new_title",$hidden_array,"admin_perm_submit_new","form_reset","complete_form","uf/","admin.php","","admin_perm_one_","text","icreator_one","uf/");
	$hidden_form = $this->uf_create_hidden_form(array("perm" => "del"));
	$this->tpl_load("perm_show","admin/");
	$this->tpl_replace_vars(array("perm_ones" => $perm_ones,"perm_new_input" => $perm_new_input,"hidden_form" => $hidden_form));
	$nc_main = $this->tpl_output();
	$stat["admin_stat_anzahl_perms"] = $this->db_anzahl_zeilen ($abfrage);
}elseif ($perm == "new") {
	$anzahl_perms_name = $this->db_anzahl_zeilen("SELECT id FROM ".$this->config["prefix"]."perm WHERE name=\"".$_POST["name"]."\"");
	if($anzahl_perms_name == 0) {
		list($return,$abfrage1,$abfrage2) = $this->uf_create_array_conf("insert");
		if ($this->uf_form_conf($return)) {
			$this->db_abfrage_q("INSERT ".$this->config["prefix"]."perm ($abfrage1) VALUES ($abfrage2)");
			$this->perm_name = $_POST["name"];
			$this->message_green[] = 9;
			$this->w_leitung["number"] = 1;
			$this->w_leitung["url"] = $this->fun_make_link("admin.php");
		}else {
			$this->message_red[] = 1;
			$this->w_leitung["number"] = 1;
		}
	}else {
		$this->message_red[] = 18;
		$this->w_leitung["number"] = 1;
	}
}elseif ($perm == "edit") {
	$perm_array = $this->db_abfrage_az("SELECT * FROM ".$this->config["prefix"]."perm WHERE id = \"$_GET[perm_id]\"");
	$hidden_array["action"] = "perm";
	$hidden_array["perm"] = "do_edit";
	$hidden_array["perm_id"] = $_GET["perm_id"];
	$nc_main = $this->uf_create_complete_form("admin_perm_edit_title",$hidden_array,"admin_perm_submit_edit","form_reset","complete_form","uf/","admin.php",$perm_array,"admin_perm_one_","text","icreator_one","uf/");
}elseif ($perm == "do_edit") {
	list($return,$abfrage) = $this->uf_create_array_conf("update");
	if ($this->uf_form_conf($return)) {
		$this->db_abfrage_q("UPDATE ".$this->config["prefix"]."perm SET $abfrage WHERE id=".$_POST["perm_id"]."");
		$this->perm_name = $_POST["name"];
		$this->message_green[] = 10;
		$this->w_leitung["number"] = 4;
		$this->w_leitung["url"] = $this->fun_make_link("admin.php","action=perm");
	}else {
		$this->message_red[] = 1;
		$this->w_leitung["number"] = 1;
	}
}elseif ($perm == "del") {
	if (isset($_POST["del_perm"])) {
		$this->anzahl = 0;
		$this->anzahl_del = 0;
		$perm_array = array();
	    	foreach ($_POST["del_perm"] as $perm_id) {
			if ($perm_id != $this->db_config["standard_perm"] AND $perm_id != $this->db_config["guest_perm"]) {
				array_push($perm_array,$perm_id);
				$this->anzahl_del++;
			}			
			$this->anzahl++;	
		}
		if ($this->anzahl_del >= 1) {
			$this->message_green[] = 11;
			$abfrage = $this->uf_create_where_part($perm_array);
			$this->db_abfrage_q("DELETE FROM ".$this->config["prefix"]."perm WHERE $abfrage");
		}else $this->message_red[] = 14 ;
	}else $this->message_red[] = 6;
	$this->w_leitung["number"] = 1;
	$this->w_leitung["url"] = $this->fun_make_link("admin.php","action=perm&perm=show");
}

?>